package com.example.financeapi.entity.vo;

/**
 * 响应工具类
 */
public class ResultVOUtil {

    /**
     * 成功
     * @return
     */
    public static ResultVo success() {
        ResultVo resultVo = new ResultVo<Object>();
        resultVo.setCode(0);
        resultVo.setMsg("成功");
        return resultVo;
    }

    /**
     * 成功返回
     * @param object 数据
     * @return
     */
    public static ResultVo success(Object object) {
        ResultVo resultVo = new ResultVo<Object>();
        resultVo.setCode(0);
        resultVo.setMsg("成功");
        resultVo.setData(object);
        return resultVo;
    }

    /**
     * 错误返回
     * @param object 数据
     * @return
     */
    public static ResultVo error(Object object) {
        ResultVo resultVo = new ResultVo<Object>();
        resultVo.setCode(1);
        resultVo.setMsg("失败");
        resultVo.setData(object);
        return resultVo;
    }

    /**
     * 错误返回
     * @param msg 错误消息
     * @param object 数据
     * @return
     */
    public static ResultVo error(String msg,Object object) {
        ResultVo resultVo = new ResultVo<Object>();
        resultVo.setCode(-1);
        resultVo.setMsg(msg);
        resultVo.setData(object);
        return resultVo;
    }

    /**
     * 错误返回
     * @param code 错误状态码
     * @param msg 错误消息
     * @return
     */
    public static ResultVo error(Integer code,String msg) {
        ResultVo resultVo  = new ResultVo();
        resultVo.setCode(code);
        resultVo.setMsg(msg);
        return resultVo;
    }

    /**
     * 错误返回
     * @param code 错误状态码
     * @param msg 错误消息
     * @return
     */
    public static ResultVo error(Integer code,String msg,Object obj) {
        ResultVo resultVo  = new ResultVo();
        resultVo.setCode(code);
        resultVo.setMsg(msg);
        resultVo.setData(obj);
        return resultVo;
    }
}
